<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        console.log(globalThis === window) //true

        let str1 = null ?? "twj"
        let str2 = undefined ?? "twj"
        let str3 = "hhh" ?? "twj"
        let str4 = 0 ?? "twj"
        let str5 = NaN ?? "twj"
        console.log(str1, str2, str3, str4, str5) //twj twj hhh 0 NaN
        let obj = {
            name: "twj",
            introduction: 0,
            // location: {
            //     city: "changsha"
            // }
        }
        console.log(obj.introduction || "这个人很懒") //这个人很懒
        console.log(obj.introduction ?? "这个人很懒") //0


        console.log(obj && obj.location && obj.location.city) //undefined
        console.log(obj?.location?.city) //undefined
        //obj或location或city不存在则返回右侧的北京
        console.log(obj?.location?.city ?? "北京") //北京

    </script>
</body>

</html>